Skip to content

Python2 String Handling Cleanup in parsers.pyx #26270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 3, 2019

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented May 3, 2019

Just removing some old Py2 cruft hanging around in parsers.pyx

@@ -671,11 +664,10 @@ cdef class TextReader:

self.handle = source

if isinstance(source, basestring):
if not isinstance(source, bytes):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get to this point in Py3 the object would have to be a str in the first place, which means it logically isn't a bytes type hence why I removed this condition altogether

@@ -21,16 +21,14 @@ from cython import Py_ssize_t
from cpython cimport (PyObject, PyBytes_FromString,
PyBytes_AsString,
PyUnicode_AsUTF8String,
PyErr_Occurred, PyErr_Fetch)
PyErr_Occurred, PyErr_Fetch,
PyUnicode_Decode)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was orthogonal but figured preferable to import this way rather than through Python header (cython doesn't expose the last remaining item coming from Python.h)

@@ -768,9 +760,7 @@ cdef class TextReader:
for i in range(field_count):
word = self.parser.words[start + i]

if path == CSTRING:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSTRING was not a possible value in this enum hence removal. See here:

cdef inline StringPath _string_path(char *encoding):

@codecov
Copy link

codecov bot commented May 3, 2019

Codecov Report

Merging #26270 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26270      +/-   ##
==========================================
- Coverage   91.99%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52379    52379              
==========================================
- Hits        48184    48180       -4     
- Misses       4195     4199       +4
Flag Coverage Δ
#multiple 90.53% <ø> (ø) ⬆️
#single 40.72% <ø> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0989339...d72d05a. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented May 3, 2019

Codecov Report

Merging #26270 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26270      +/-   ##
==========================================
- Coverage   91.99%   91.98%   -0.01%     
==========================================
  Files         175      175              
  Lines       52379    52379              
==========================================
- Hits        48184    48180       -4     
- Misses       4195     4199       +4
Flag Coverage Δ
#multiple 90.53% <ø> (ø) ⬆️
#single 40.72% <ø> (-0.15%) ⬇️
Impacted Files Coverage Δ
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0989339...d72d05a. Read the comment docs.

@gfyoung gfyoung added the IO CSV read_csv, to_csv label May 3, 2019
Copy link
Member

@gfyoung gfyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@jreback jreback added this to the 0.25.0 milestone May 3, 2019
@jreback jreback merged commit a8d61d3 into pandas-dev:master May 3, 2019
@jreback
Copy link
Contributor

jreback commented May 3, 2019

thanks @WillAyd

@WillAyd WillAyd deleted the remove-basestring branch January 16, 2020 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants